<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    function Parent(m){
        this.title = "这是构造函数中的属性"
        this.msg = m;
    }
    Parent.prototype.init = function(){
        console.log(this.msg)
    }

    function Child(){}

    // 将Child的原型对象设置为Parent的实例
    Child.prototype = new Parent("world");

    // Child.prototype.init = function(){
    //     console.log("Child的init")
    // }

    
    const p = new Parent("hello");
    console.log(p);
    // console.log(p.title)
    p.init();
    // console.log(p.init);
    
    const c = new Child();
    console.log(c);
    // console.log(c.title);
    // console.log(c.init);
    c.init();
    
</script>
</html>